package com.qf.mpswaggershiro.product.controller;

import com.qf.mpswaggershiro.product.entity.ProductComments;
import com.qf.mpswaggershiro.product.service.IProductCommentsService;
import com.qf.mpswaggershiro.product.service.IProductService;
import com.qf.mpswaggershiro.product.entity.ProductParams;
import com.qf.mpswaggershiro.product.service.IProductParamsService;
import com.qf.mpswaggershiro.vo.DetailCommontscountVo;
import com.qf.mpswaggershiro.vo.ProductInfoVo;
import com.qf.mpswaggershiro.vo.Vo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 商品图片  前端控制器
 * </p>
 *
 * @author cui
 * @since 2023-02-13
 */
@RestController
@RequestMapping("/product")
@CrossOrigin
public class ProductImgController {
    @Autowired
    IProductService productService;

    @Autowired
    IProductParamsService productParamsService;
    @Autowired
    IProductCommentsService productCommentsService;

    @GetMapping("/detail-info/{id}")
    public Vo product(@PathVariable("id") Integer id){

        //1.提供注册接口
       ProductInfoVo data= productService.listproductInfo(id);
//5.返回数据额给页面
        return Vo.ok(data);
    }
    @GetMapping("/detail-params/{id}")
    public Vo productParams(@PathVariable("id") Integer id){

       ProductParams data= productParamsService.productParams(id);

return Vo.ok(data);
    }
    @GetMapping("/detail-commonts/{id}")
    public Vo detailCommonts(@PathVariable("id") Integer id,Integer pageNum,Integer limit){

       Map<String,Object> data= productCommentsService.commints(id,pageNum,limit);

       return Vo.ok(data);

    }
    @GetMapping("/detail-commontscount/{id}")
    public Vo detailCommontscount(@PathVariable("id") Integer id){

       DetailCommontscountVo data= productCommentsService.detailCommontscount(id);

       return Vo.ok(data);

    }

}
